﻿using System;
using System.IO;
using System.Text;
using Kugar.Core.Configuration;
using Kugar.Core.ExtMethod;
using Newtonsoft.Json.Linq;

namespace Kugar.Tools.CityToolUpdater
{
    class Program
    {
        static void Main(string[] args)
        {
            var type = CustomConfigManager.Default["Type"].ToLower();

            var text = File.ReadAllText("city.json", Encoding.UTF8);
            var data = JArray.Parse(text);

            switch (type)
            {
                case "mongo":
                case "mongodb":
                {
                    var conn = CustomConfigManager.Default["Mongo:Conn"];
                    new MongoDBExecutor(conn).Execute(data);
                    break;
                }
                case "mssql":
                {
                    var conn = CustomConfigManager.Default["MSSQL:Conn"];
                    new MsSQLExecutor(conn).Execute(data);
                    break;
                }
            }

            Console.WriteLine("输出完成");

            Console.ReadLine();
        }
    }
}
